<?php
session_start();
$email = $_POST['txtEmail'];
$pwd = $_POST["txtPwd"];

$host = "localhost";//127.0.0.1
$username = "root";
$password = "";
$db_name = "forum";

mysql_connect("$host", "$username", "$password") 
or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$pwd = stripslashes($pwd);
$pwd = mysql_real_escape_string($pwd);

$sql = "SELECT * FROM forumuser WHERE Email = '$email' 
		AND pwd = '$pwd' AND IsActive = 1";

//echo $sql."<br />";

$result = mysql_query($sql);
$count = mysql_num_rows($result);
mysql_close();
if($count > 0)
{
	$recordSet = mysql_fetch_array($result);

	$_SESSION['fname'] = $recordSet["fname"];
	$_SESSION['UserId'] = $recordSet["id"];
	header("location:AskQues.php");
}
else
{
	//echo "<b>Login Fail</b>";
	header("location:Index.php?status=fail");
}
?>